#!/usr/bin/env ruby

class Composite < Xml

  attr_accessor :services, :components, :references, :pom

  def references
    if isDoc?
      return @references = doc.xpath('//xmlns:reference',doc.root.namespaces)
    end
    nil
  end

  def locations
    if isDoc?
      return @locations = references.xpath('//xmlns:binding.ws/@location',doc.root.namespaces)
    end
    nil
  end

  def versionUp(vers = nil)
    if vers.to_s==""
      version.revision=version.revision.to_i+1
    else
      version.version=vers
    end
    versionNode.content=version.version.to_s
    pom.version=version.version.to_s
    info
  end
  
  def pom
    @pom=Pom.new(@path.split("/")[0...-1].join("/")+"/pom.xml") if @pom==nil
    @pom
  end

  def svn
    @svn=Svn.new @path if @svn==nil
    @svn
  end

  def info
    super.merge("pom" => pom)
  end

  def push
    pom.push
    super
  end

  def createTag(message=nil)
    svn.newTag(version,message)
    versionUp
    push
    svn.commit
    info
  end

end

